/**
 * @author huangliang
 * 表格行编辑
 * 数据对象：
 * 		deleteIds 待删除的持久化行
 * 		updateObjs 修改行
 * 		addObjs 新增行
 * 
 * 状态：
 * 		flagPersistence：是否是持久化行   true:持久化   false:非持久化
 * 		flagEdit ：是否处于编辑状态	true ：编辑   false 非编辑
 * 		is-new-edit ： 是否是新行确认后，再次双击修改，用于此类操作后，点【回滚】后，如果为：true时，避免此操作会直接删除新行
 * 		
 * 功能：
 * 		1.新增行
 * 		2.删除行（持久化和非持久化）
 * 		3.双击行修改
 * 		
 *		4.提交（commit）
 *		5.回滚（rollback) 
 *
 *		6.刷新表格（未实现 -> 前提条件：表格数据异步加载）
 *		
 *		7.验证行数据（此功能做在【提交】功能里）
 * 
 * 逻辑：
 * 		1.新增：
 * 				新增按钮 -> 新增空行 -> 空行标志为：flagPersistence =false ;  flagEdit = true ;
 * 		
 * 		2.修改行：
 * 				双击行  -> 判断flagEdit = true 行数等于0 -> 修改持久化行  -> 行标志为：flagEdit = true -> 提交  -> 保存数据至：updateObjs
 * 									   																-> 回滚  -> 不保存数据
 * 
 * 					   									-> 修改非持久化行 -> 行标志为：flagEdit = true  ->  提交 -> 删除addObjs里对应的记录  -> 当前数据添加到 addObjs 
 * 										 								 							  ->  回滚 -> 不保存数据
 * 		3.删除行 
 * 				选中行（单行或多行） -> 删除 -> 持久化行 -> 记录ID到deleteIds
 * 										   -> 非持久化行 -> 清理 addObjs里的对应数据
 * 		4.提交
 * 			新增提交  -> 
 * 			修改提交  -> 持久化提交
 * 					  -> 非持久分提交
 * 		5.回滚
 * 			新增回滚  -> 
 * 			修改回滚  -> 持久化回滚
 * 					 -> 非持久化回滚
 */

/*********************************************表格JS****start*******************************************/
	
		//是否是持久化行
		//var flagPersistence ;
		//是否处于编辑状态
		//var flagEdit;
		
		//要删除的ID串，以"," 分隔
		var deleteIds=new Array();
		//要修改的记录
		var updateObjs=new Array();
		var addObjs = new Array();
		
		$(function(){
			$(".certificate table tbody tr").on("dblclick",function(){
				if($(this).attr("flag-edit") == true || $(this).attr("flag-edit") == 'true'){
					return ;
				}
				editRow(this);
			});
			
		});
		
		//得到当行处于编辑状态的行数
		function checkEditCount(){
			var $tbody =  $("#certificateList tbody");
			var len = $tbody.children("tr[flag-edit='true']").length;
			return len;
		}
		
		//选中
		function getCurrentRow(){
			var $tbody =  $("#certificateList tbody");
			var currentRow = $tbody.children("tr[flag-edit='true']");
			return currentRow;
		}
		
		//添加
		function addRow(){
			
			var html = new Array();
			
			var $tbody =  $("#certificateList tbody");
			
			//有未编辑状态行时，不能添加新行
			if(checkEditCount() != 0){
				alert("请确认正在编辑的行");
				return ;
			}
			
			//序号
			var index = $tbody.children("tr").length-1;
			
			var spanHtml = '<td><span class="hidden"></span>';
			
			html.push('<tr flag-edit="true" flag-persistence="false" class="currentEdit" >');
			
			html.push('<td><input type="checkbox" name="rowCheck" value="'+addObjs.length+'"></td>');
			html.push(spanHtml);
			html.push('<input type="hidden" name="typeOne" data-name="">');
			html.push('<input type="hidden" name="typeTwo" data-name="">');
			html.push('<input type="hidden" name="typeLevel" data-name="">');
			html.push('<div class="input-group">');
			html.push('<input type="text" id="showTypeLevel" class="form-control" placeholder="资质类型" readonly="readonly">');
			html.push('<span class="input-group-btn">');
			html.push('<button class="btn btn-default" type="button">选择</button>');
			html.push('</span></div>');
			html.push('</td>');
			
			var input = "";
			//单选组+备注框
			var radioGroup = new Array();
			radioGroup.push('');
			radioGroup.push('<div class="btn-group" data-toggle="buttons">');
			radioGroup.push('<label class="btn btn-default btu-padding active">');
			radioGroup.push('<input type="radio" name="cfeIncludeSafetyState" autocomplete="off" value="1"> 无');
			radioGroup.push('</label>');
			radioGroup.push('<label class="btn btn-default btu-padding">');
			radioGroup.push('<input type="radio" name="cfeIncludeSafetyState" autocomplete="off" value="2"> 有');
			radioGroup.push('</label>');
			radioGroup.push('<input type="text" class="form-control input-control hidden" name="descText">');
			radioGroup.push('</div>');
			
			var timerGroup = new Array();
			timerGroup.push('<div class="input-group date" id="datetimepicker'+index+'">');
			timerGroup.push('<input type="text" name="validDate" class="form-control Wdate input-timer" onFocus="WdatePicker({dateFmt: \'yyyy-MM-dd\',lang:\'zh-cn\',readOnly:true})" placeholder="有效期">');
			timerGroup.push('</div>');
			
			//安全生产许可证     使用  单选组+日期框
			var safeGroup = new Array();
			safeGroup.push('<div class="btn-group" data-toggle="buttons">');
			safeGroup.push('<label class="btn btn-default btu-padding active">');
			safeGroup.push('<input type="radio" name="cfeIncludeSafetyState" autocomplete="off" value="1"> 无');
			safeGroup.push('</label>');
			safeGroup.push('<label class="btn btn-default btu-padding">');
			safeGroup.push('<input type="radio" name="cfeIncludeSafetyState" autocomplete="off" value="2"> 有');
			safeGroup.push('</label>');
			safeGroup.push('<div class="input-group date hidden">');
			safeGroup.push('<input type="text" name="descText" class="form-control Wdate input-timer td-input-timer " onFocus="WdatePicker({dateFmt: \'yyyy-MM-dd\',lang:\'zh-cn\',readOnly:true})" placeholder="有效期">');
			safeGroup.push('</div>');
			safeGroup.push('</div>');
			
			html.push(spanHtml);
			input = "<input type='text' placeholder='证书编号'>";
			html.push(input);
			html.push('</td>');
			
			html.push(spanHtml);
			//input = "<input type='text'placeholder='证书有效期'>";
			//html.push(input);
			html.push(timerGroup.join(" "));
			html.push('</td>');
			
			html.push(spanHtml);
			input = "<input type='text' placeholder='发证机关'>";
			html.push(input);
			html.push('</td>');
			//安全生产许可证
			html.push(spanHtml);
			html.push('<input type="hidden" name="state" value="1">');
			html.push('<input type="hidden" name="desc" value="">');
			html.push(safeGroup.join(" "));
			html.push('</td>');
			//建造师
			html.push(spanHtml);
			html.push('<input type="hidden" name="state" value="1">');
			html.push('<input type="hidden" name="desc" value="">');
			html.push(radioGroup.join(" "));
			html.push('</td>');
			//是否有在建工程
			html.push(spanHtml);
			html.push('<input type="hidden" name="state" value="1">');
			html.push('<input type="hidden" name="desc" value="">');
			html.push(radioGroup.join(" "));
			html.push('</td>');
			
			html.push('</tr>');
			
			$tbody.append(html.join(' '));
			//为新增行绑定双击事件
			
			$(".certificate table tbody tr:last").on("dblclick",function(){
				editRow(this);
			});
			
			//为新加元素绑定事件、
			$tbody.children("tr:last").find(".btn-group .btn.btn-default.btu-padding").on('click',function(index){
				var thisV =  $(this).children("input:radio").val();
				var $nextObj = "";
				if($(this).parent().children("input[name='descText']").length != 0){
					$nextObj = $(this).parent().children("input[name='descText']");
				}else{
					$nextObj = $(this).parent().children("div.input-group.date")
				}
				if(thisV == 2 ){
					$nextObj.removeClass("hidden");
				}else{
					$nextObj.addClass("hidden");
				}
			});
			//选择资质类型绑定事件
			$tbody.children("tr:last").find("#showTypeLevel").next().children("button").on('click',function(){
				openChooseType();
			});
			
		}
	
		//修改
		function editRow(obj){
			
			$(obj).addClass("currentEdit");
			
			//保持单行编辑
			if(checkEditCount()!=0){
				alert("请确认正在编辑的行");
				return ;
			}
			
			if($(obj).attr("flag-edit") == "false" || $(obj).attr("flag-edit") ==false || $(obj).attr("flag-edit") == undefined){
				$(obj).attr("flag-edit","true");
				//如果是非持久化持，就为该行加上：is-new-edit = true 标记该行为新行再次编辑
				var flagPersistence = $(obj).attr("flag-persistence");
				if(flagPersistence == false || flagPersistence == 'false' || flagPersistence == undefined){
					$(obj).attr("is-new-edit",true);
				}
			}else{
				return;
			}
			
			var childNodes = obj.childNodes;
			var outerText = obj.outerText;
			$(obj).children("td").each(function (index){
				
				if(index == 0){
					return ;
				}
				var thisSpan = $(this).children('span');
				var innerText = $(thisSpan).text();
				$(this).children('span').hide();
				
				if(index == 1){
					var html =new Array();
					html.push('<div class="input-group">');
					html.push('<input type="text" id="showTypeLevel" class="form-control" value="'+innerText+'" readonly="readonly">');
					html.push('<span class="input-group-btn">');
					html.push('<button class="btn btn-default" type="button">选择</button>');
					html.push('</span>');
					html.push('</div>');
					$(this).append(html.join(" "));
					
					//为新加选择类型绑定事件
					$(this).find("#showTypeLevel").next().children("button").on('click',function(){
						openChooseType();
					});
					return 1;
				}
				if(index == 3){
					var timerGroup = new Array();
					timerGroup.push('<div class="input-group date" id="datetimepicker'+(index+1)+'">');
					timerGroup.push('<input type="text" value="'+innerText+'" name="validDate" class="form-control Wdate input-timer" onFocus="WdatePicker({dateFmt: \'yyyy-MM-dd\',lang:\'zh-cn\',readOnly:true})" placeholder="有效期">');
					timerGroup.push('</div>');
					$(this).append(timerGroup.join(" "));
					return 1
				}
				if(index == 5){
					//单选组+日期框
					var radioGroup = new Array();
					radioGroup.push('<div class="btn-group" data-toggle="buttons">');
					radioGroup.push('<label class="btn btn-default btu-padding active">');
					radioGroup.push('<input type="radio" name="cfeIncludeSafetyState" autocomplete="off" value="1"> 无');
					radioGroup.push('</label>');
					radioGroup.push('<label class="btn btn-default btu-padding">');
					radioGroup.push('<input type="radio" name="cfeIncludeSafetyState" autocomplete="off" value="2"> 有');
					radioGroup.push('</label>');
					radioGroup.push('<div class="input-group date hidden">');
					radioGroup.push('<input type="text" name="descText" class="form-control Wdate input-timer td-input-timer " onFocus="WdatePicker({dateFmt: \'yyyy-MM-dd\',lang:\'zh-cn\',readOnly:true})" placeholder="有效期">');
					radioGroup.push('</div>');
					radioGroup.push('</div>');
					
					$(this).append(radioGroup.join(" "));
					
					//为新加元素绑定事件、
					$(this).find(".btn-group .btn.btn-default.btu-padding").on('click',function(){
						var thisV =  $(this).children("input:radio").val();
						if(thisV == 2 ){
							$(this).parent().children("div.input-group.date").removeClass("hidden");
						}else{
							$(this).parent().children("div.input-group.date").addClass("hidden");
						}
					});
					
					//设置默认值：在修改时使用
					var state = $(this).children("input[name='state']").val();
					//备注
					var desc = $(this).children("input[name='desc']").val();
					if(state == 2){
						$(this).find(".btn-group").children("div.input-group.date").children("input[name='descText']").val(desc);
						$(this).find(".btn-group .btn.btn-default.btu-padding:last").click();
					}
					return 1
				}
				if(index >5){
					//单选组+备注框
					var radioGroup = new Array();
					radioGroup.push('<div class="btn-group" data-toggle="buttons">');
					radioGroup.push('<label class="btn btn-default btu-padding active">');
					radioGroup.push('<input type="radio" name="cfeIncludeSafetyState" autocomplete="off" value="1"> 无');
					radioGroup.push('</label>');
					radioGroup.push('<label class="btn btn-default btu-padding">');
					radioGroup.push('<input type="radio" name="cfeIncludeSafetyState" autocomplete="off" value="2"> 有');
					radioGroup.push('</label>');
					radioGroup.push('<input type="text" class="form-control input-control hidden" name="descText">');
					radioGroup.push('</div>');
					$(this).append(radioGroup.join(" "));
					
					//为新加元素绑定事件、
					$(this).find(".btn-group .btn.btn-default.btu-padding").on('click',function(){
						var thisV =  $(this).children("input:radio").val();
						if(thisV == 2 ){
							$(this).parent().children("input").removeClass("hidden");
						}else{
							$(this).parent().children("input").addClass("hidden");
						}
					});
					
					//设置默认值：在修改时使用
					
					//得到当状态：
					var state = $(this).children("input[name='state']").val();
					//备注
					var desc = $(this).children("input[name='desc']").val();
					if(state == 2){
						$(this).find(".btn-group").children("input[name='descText']").val(desc);
						$(this).find(".btn-group .btn.btn-default.btu-padding:last").click();
					}
					return 1
				}
				if(index == 2 || index == 4 ){
					var html = "<input type='text' value='"+innerText+"'>";
					$(this).append(html);
					return 1;
				}
			});
		}
		
		//删除行
		function delRow(){
			$("input:checkbox[name='rowCheck']:checked").each(function(){
				var $tr = $(this).parent().parent();
				if($tr.attr("flag-persistence") == "true" || $tr.attr("flag-persistence") == true ){
					deleteIds.push($(this).val());
				}else{
					checkUnique($(this).val(),3);
				}
				$tr.remove();
			});
		}
		
		//确认
		function commit(){
			//获取当前行
			var currentRow = getCurrentRow();
			if(currentRow.length == 0){
				return ;
			}
			var flagPersistence = currentRow.attr("flag-persistence");
			var recordId = "";
			//如果是持久化行，ID为数据库ID，否则为addObjs对象个数的，从0开始
			recordId = currentRow.find("td:first input:checkbox[name='rowCheck']").val();
			debugger;
			//证书等级类型编号     后台通过该字段查询对应的一级、二级、三级的信息
			var cfeTypeOneCode = currentRow.find("td:eq(1) input[name='typeOne']").val();
			var cfeTypeOneName = currentRow.find("td:eq(1) input[name='typeOne']").attr("data-name");
			var cfeTypeTwoCode = currentRow.find("td:eq(1) input[name='typeTwo']").val();
			var cfeTypeTwoName = currentRow.find("td:eq(1) input[name='typeTwo']").attr("data-name");
			var cfeTypeLevelCode = currentRow.find("td:eq(1) input[name='typeLevel']").val();
			var cfeTypeLevelName = currentRow.find("td:eq(1) input[name='typeLevel']").attr("data-name");
			
			//证书编号
			var cfeCode =currentRow.find("td:eq(2) input:text").val();
			//证书有效期
			var cfeValidDate = currentRow.find("td:eq(3) input[name='validDate']").val();
			//发证机关
			var cfeAwardOrg = currentRow.find("td:eq(4) input:text").val();
			
			//是否包含安全生产许可证：1 没有   2 有
			var cfeIncludeSafetyState=currentRow.find("td:eq(5)").find(".btn-group .btn.btn-default.btu-padding.active input:radio").val();
			//安全生产许可证有效期
			var cfeIncludeSafetyValidDate = currentRow.find("td:eq(5)").find(".btn-group .input-group.date input").val();
			
			//建造师 : 1 没有 2 有
			var cfeIncludeArchitectState=currentRow.find("td:eq(6)").find(".btn-group .btn.btn-default.btu-padding.active input:radio").val();
			//有建筑师时的备注
			var cfeIncludeArchitectDesc = currentRow.find("td:eq(6)").find(".btn-group input[name='descText']").val();
			
			//是否有在建工程：1 没有  2 有
			var cfeIncludeBulidingProjectState=currentRow.find("td:eq(7)").find(".btn-group .btn.btn-default.btu-padding.active input:radio").val();
			//有在建工程时的备注
			var cfeIncludeBulidingProjectDesc = currentRow.find("td:eq(7)").find(".btn-group input[name='descText']").val();
			
			//数据验证
			if( !isNull(cfeTypeOneCode) || !isNull(cfeTypeTwoCode) || !isNull(cfeTypeLevelCode) ){
				layer.msg("请选择资质类型");
				return ;
			}
			if(!isNull(cfeCode)){
				layer.msg("请输入证书编号");
				return ;
			}
			if(!isNull(cfeValidDate)){
				layer.msg("请选择证书有效期");
				return ;
			}
			if(!isNull(cfeAwardOrg)){
				layer.msg("请输入发证机关");
				return ;
			}
			
			/*if(cfeIncludeSafetyState == 2){
				if(!isNull(cfeIncludeSafetyValidDate)){
					layer.msg("请选择生产许可证书有效期");
					return ;
				}
			}*/
			if(cfeIncludeArchitectState == 2){
				if(!isNull(cfeIncludeArchitectDesc)){
					layer.msg("请输入建造师备注");
					return ;
				}
			}
			if(cfeIncludeBulidingProjectState == 2){
				if(!isNull(cfeIncludeBulidingProjectDesc)){
					layer.msg("请输入在建工程备注");
					return ;
				}
			}
			
			
			//记录做过修改的字段
			var obj = {};
			obj.cfeId = recordId;
			//类型
			obj.cfeTypeOneCode = cfeTypeOneCode;
			obj.cfeTypeOneName = cfeTypeOneName;
			obj.cfeTypeTwoCode = cfeTypeTwoCode;
			obj.cfeTypeTwoName = cfeTypeTwoName;
			obj.cfeTypeLevelCode = cfeTypeLevelCode;
			obj.cfeTypeLevelName = cfeTypeLevelName;
			
			obj.cfeTypeLevelCode = cfeTypeLevelCode;
			
			obj.cfeCode = cfeCode;
			obj.cfeValidDate = cfeValidDate;
			obj.cfeAwardOrg = cfeAwardOrg;
			
			obj.cfeIncludeSafetyState = cfeIncludeSafetyState;
			obj.cfeIncludeSafetyValidDate = cfeIncludeSafetyValidDate;
			
			obj.cfeIncludeArchitectState = cfeIncludeArchitectState;
			obj.cfeIncludeArchitectDesc = cfeIncludeArchitectDesc;
			
			obj.cfeIncludeBulidingProjectState = cfeIncludeBulidingProjectState;
			obj.cfeIncludeBulidingProjectDesc = cfeIncludeBulidingProjectDesc;
			
			if(flagPersistence == true || flagPersistence == 'true'){
				//元素去重
				checkUnique(recordId,1);
				//持久化行
				updateObjs.push(obj);
			}else{
				checkUnique(recordId,3);
				addObjs.push(obj);
			}
			
			//commit后 ，取消编辑状态
			removeEdit(1);
		}
		
		//回滚
		function rollback(){
			//获取当前编辑行
			var currentRow = getCurrentRow();
			if(currentRow.length == 0){
				return;
			}
			var flagPersistence = currentRow.attr("flag-persistence");
			if(flagPersistence == true || flagPersistence == 'true'){
				//持久化行
				//回滚 ，取消编辑状态
				removeEdit(2);
			}else{
				var isNewEdit = currentRow.attr("is-new-edit");
				if(isNewEdit == true || isNewEdit == 'true'){
					//非持久化行，修改后，回滚
					removeEdit(2);
				}else{
					//新行，回滚则删除新行
					currentRow.remove();
				}
			}
		}
		
		/*
		*取消编辑状态
		*status：
			1  表示commit
			2 表示 rollback
		*/
		function removeEdit(status){
			//获取当前编辑行
			var currentRow = getCurrentRow();
			currentRow.removeClass("currentEdit");
			
			currentRow.attr('flag-edit','false');
			
			$(currentRow).children("td").each(function (index){
				if(index == 0){
					return 1;
				}
				var thisSpan = $(this).children('span');
				//var innerText = $(thisSpan).text();
				
				if(status == 2 ){
					//回滚
					if(index == 1 || index == 3 || index == 5 || index == 6 || index == 7 ){
						$(this).children("div").remove();
						thisSpan.show();
					}else{
						$(this).children("input").remove();
						thisSpan.show();
					}
				}else{
					//提交commit
					var inputText="";
					if(index == 1){
						//类型
						var typeText = $(this).children("div").find("input").val();
						inputText = typeText;
						$(this).children("div").remove();
					}else if(index == 5){
						//生产许可证
						var state=$(this).find(".btn-group .btn.btn-default.btu-padding.active input:radio").val();
						var desc = $(this).find(".btn-group .input-group.date input").val();
						if(state == 2 ){
							$(this).children("input[name='state']").val(state);
							$(this).children("input[name='desc']").val(desc);
							inputText = "<strong>有</strong>";
							inputText += "    注：有效期至"+desc;
						}else{
							$(this).children("input[name='state']").val(state);
							$(this).children("input[name='desc']").val("");
							inputText = "无";
						}
						$(this).children("div").remove();
						
					}else if(index == 6 || index == 7 ){
						//6：建造师  7：在建工程 
						var state=$(this).find(".btn-group .btn.btn-default.btu-padding.active input:radio").val();
						var desc = $(this).find(".btn-group input[name='descText']").val();
						if(state == 2 ){
							$(this).children("input[name='state']").val(state);
							$(this).children("input[name='desc']").val(desc);
							inputText = "<strong>有</strong>";
							inputText += "    注："+desc;
						}else{
							$(this).children("input[name='state']").val(state);
							$(this).children("input[name='desc']").val("");
							inputText = "无";
						}
						$(this).children("div").remove();
					}else if(index == 3){
						var validDate = $(this).find("div input[name='validDate']").val();
						inputText = validDate;
						$(this).children("div").remove();
					}else{
						inputText = $(this).children("input").val();
						$(this).children("input").remove();
					}
					thisSpan.html(inputText);
					thisSpan.removeClass("hidden");
					thisSpan.show();
					
				}
			});
		}
		
		/**
			确认时去掉重复的值 
			id:去重的ID
			flag: 去重对象的类型：
				1 update 
				2 delete
				3 add
		*/
		function checkUnique (id,flag){
			if(flag == 1 ){
				for(var i = 0 , j = updateObjs.length;i<j;i++){
					var thisId = updateObjs[i].cfeId;
					if(thisId == id){
						//删除指定下标的元素
						updateObjs.splice(i,1);
					}
				}
				return ;
			}
			if(flag == 2 ){
				for(var i = 0 , j = deleteIds.length;i<j;i++){
					var thisId = deleteIds[i];
					if(thisId == id){
						//删除指定下标的元素
						deleteIds.splice(i,1);
					}
				}
				return ;
			}
			if(flag == 3){
				for(var i = 0 , j = addObjs.length;i<j;i++){
					var thisId = addObjs[i].cfeId;
					if(thisId == id){
						//删除指定下标的元素
						addObjs.splice(i,1);
					}
				}
				return ;
			}
		}
		
		/*********************************选资质类型  start*******************************/
		var indexTypeModel;
		//打开选择类型窗口
		function openChooseType(){
			indexTypeModel = layer.open({
			      type: 2,
			      title: '资质类型选择',
			      area: ['430px', '450px'],
			      content: rootpath+'/certificate/loadCerType.shtml',
			      btn: ['选择','取消'],
			      yes: function(index, layero){
			    	  var iframe="layui-layer-iframe"+index;
			    	  document.getElementById(iframe).contentWindow.yes(); 
			      },
			  });
		}
		//开放给child窗口使用的方法:修改机构
		function changeType(fristNode,secondNode,node){
			//获取当前行
			var $currentRow = getCurrentRow();
			$currentRow.find("input[name='typeOne']").val(fristNode.cfeTypeCode);
			$currentRow.find("input[name='typeOne']").attr("data-name",fristNode.cfeTypeName);
			$currentRow.find("input[name='typeTwo']").val(secondNode.cfeTypeCode);
			$currentRow.find("input[name='typeTwo']").attr("data-name",secondNode.cfeTypeName);
			$currentRow.find("input[name='typeLevel']").val(node.cfeTypeCode);
			$currentRow.find("input[name='typeLevel']").attr("data-name",node.cfeTypeName);
			
			var showValue = secondNode.cfeTypeName.substring(0,5)+"...【"+node.cfeTypeName+"】";
			$currentRow.find("#showTypeLevel").val(showValue);
		}
		
		//开放给child窗口使用的方法:关闭弹窗
		function closeModel(){
			layer.close(indexTypeModel);
		}
		/*********************************************验证**start*********************************************/
		function isNull(str){
			if(str == null || str == '' || str == undefined ){
				return false;
			}
			return true;
		}
		
		/*********************************************表格JS**END*********************************************/